from fastapi import APIRouter
from sqlalchemy.orm import Session

from app.api.deps import DbDependency
from app.crud import attr_service
from app.schemas.attribute import AttributeBo, AttributeGroupBo

router = APIRouter()


@router.get("/list", description="属性列表")
def list_attr(db: DbDependency, categoryId: int):
    return attr_service.query_att_by_category_id(db, categoryId)


@router.post("/group/modify", description="分组新增或修改")
def att_group_modify( db: DbDependency,att: AttributeGroupBo):
    return attr_service.att_group_modify(db, att)


@router.post("/att/modify", description="属性新增或修改")
def att_modify(db: DbDependency, att: AttributeBo):
    return attr_service.att_modify(db, att)
